﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IronPhpConsole {
    public class TestResponse {
        public string Name { get; set; }
        public TimeSpan Time { get; set; }

        public bool Success { get; set; }

        public string Output { get; set; }

        public void ReportComparison(TestResponse other) {
            
            if (!this.Success) {
                Console.WriteLine("FAILED TO RUN: \t{0}", this.Name);
            }

            if (!other.Success) {
                Console.WriteLine("FAILED TO RUN: \t{0}", other.Name);
            }

            var otherFastest = this.Time > other.Time;
            Console.ForegroundColor = otherFastest ? ConsoleColor.Green : ConsoleColor.Red;
            Console.WriteLine("Fastest: \t{0}", otherFastest ? other.Name : this.Name);
            Console.ForegroundColor = ConsoleColor.Gray;

            var matched = this.Output.CompareTo(other.Output) == 0;
            Console.ForegroundColor = matched ? ConsoleColor.Green : ConsoleColor.Red;
            Console.WriteLine("Output Matched: \t{0}", matched ? "TRUE" : "FALSE");
            Console.ForegroundColor = ConsoleColor.Gray;

            Console.WriteLine();

            Console.WriteLine("{0} Output:", this.Name);
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.Write("{0}\n\n", this.Output);
            Console.BackgroundColor = ConsoleColor.Black;

            Console.WriteLine("{0} Output:", other.Name);
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.Write("{0}\n\n", other.Output);
            Console.BackgroundColor = ConsoleColor.Black;  

        }
    }
}
